package com.example.bookManagement.enmus;


import lombok.Getter;

@Getter
public enum BookStatus {
    DELETED(0,"删除"),
    NORMAL(1,"可借阅"),
    FORBIDDEN(2,"不可借阅")
  ;
    private Integer code;
    private String name;
    BookStatus(int code, String name) {
        this.code = code;
        this.name = name;
    }
    public static BookStatus getNameByCode(int code) {
        return switch (code) {
            case 0 -> DELETED;
            case 1 -> NORMAL;
            case 2 -> FORBIDDEN;
            default -> null;
        };
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setName(String name) {
        this.name = name;
    }
}
